#include<iostream>
#include<iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <unistd.h>
//这个文件的任务就是读取管道文件的数据
int main()
{
    int n = open("fifo",O_RDONLY);
    if(n < 0) std :: cout << "open filed" << std :: endl;
    else std :: cout << "open success" << std :: endl;
    //通过循环的方式去读
    while(true)
    {
        char buffer[1024];
        int number = read(n,buffer,sizeof(buffer) - 1);
        if(number > 0)
        {
            buffer[number] = 0;
            std :: cout << "Client say#" << buffer << std :: endl;
        }
        else if(number == 0)  //此时什么数据也没有读到，说明写关闭了，但是读继续了
        {
            std :: cout << "client quit! me too!" << std :: endl;
            break;
        }
        else
        {
            std :: cerr << "read error" << std :: endl;
            break;
        }
    }
    return 0;
}